package server.content.skills;

import core.util.Misc;
import server.event.CycleEvent;
import server.event.CycleEventContainer;
import server.event.CycleEventHandler;
import server.event.Event;
import server.event.EventContainer;
import server.event.EventManager;
import server.game.players.Client;

/**
 * 
 * @author Mod Miracle
 * 
 */
public class MAgility extends server.content.skilling.PlayerSkill {

	public MAgility(Client c, int skillId) {
		super(c, skillId);

	}

	@Override
	public void init() {
		kill();
		switch (getClient().objectId) {
		default:
			Misc.println("Object ID: " + getClient().objectId);
			break;
		}
	}

	@Override
	public void process() {
		CycleEventHandler.getSingleton().addEvent(getClient(),
				new CycleEvent() {

					@Override
					public void execute(CycleEventContainer container) {

					}

					@Override
					public void stop() {

					}
				}, 2);
	}

	public void travel(final int x, final int y) {
		getClient().getPA().walkTo(x, y);
	}

	public void climbUp(final int anim) {
		getClient().turnPlayerTo(getClient().objectX, getClient().objectY);
		doAnimation(anim);
		EventManager.getSingleton().addEvent(new Event() {

			@Override
			public void execute(EventContainer container) {
				getClient().getPA().movePlayer(getClient().getX(),
						getClient().getY(), getClient().getHeightLevel() + 1);

			}
		}, 4);
	}

	public void climbDown(final int anim) {
		getClient().turnPlayerTo(getClient().objectX, getClient().objectY);
		doAnimation(anim);
		EventManager.getSingleton().addEvent(new Event() {

			@Override
			public void execute(EventContainer container) {
				if (getClient().getHeightLevel() > 0)
					getClient().getPA().movePlayer(getClient().getX(),
							getClient().getY(),
							getClient().getHeightLevel() - 1);

			}
		}, 4);
	}

	@Override
	public void kill() {
		setActive(false);
	}

}
